package com.example.alipay.dsvs;

import cn.org.bjca.client.exceptions.ApplicationNotFoundException;
import cn.org.bjca.client.exceptions.InitException;
import cn.org.bjca.client.exceptions.ParameterTooLongException;
import cn.org.bjca.client.exceptions.SVSConnectException;
import cn.org.bjca.client.security.SecurityEngineDeal;
import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.test.autoconfigure.webservices.client.WebServiceClientTest;

public class Dsvs {
    SecurityEngineDeal sed = null;
    @Before
    public void init() throws ApplicationNotFoundException, InitException, SVSConnectException {
        SecurityEngineDeal.setProfilePath("C:\\BJCAROOT");

        sed = SecurityEngineDeal.getInstance("SVSDefaultSM2");
        if(sed!=null){
            System.out.println(sed);
            System.out.println("连接dsvs服务器成功");

        }else {
            System.out.println("连接dsvs服务器失败");
        }

    }

    /**
     * 获取服务端证书
     */
    @Test
    public void getServeCert() throws SVSConnectException {
        String strServerCert = sed.getServerCertificate();
        System.out.println("服务器证书："+strServerCert);
    }

    /**
     * 服务端签名
     * @throws ParameterTooLongException
     * @throws SVSConnectException
     */
    @Test
    public void  sign() throws ParameterTooLongException, SVSConnectException {
        String s = sed.signData("5YyX5LqsQ0HmrKLov47kvaA=");
        System.out.println("签名值："+s);
    }
}
